<?php

/**
 * [PHPFOX_HEADER]
 */
defined('PHPFOX') or exit('No direct script access allowed.');

/**
 *
 *
 */
class Profiles_Service_Callback extends Phpfox_Service {

	/**
	 * Class constructor
	 */
	public function __construct()
	{
		$this->_sTable = Phpfox::getT('ko_profiles');

	}
    
    public function getNotificationInvitefirends($aNotification){
        $sender_id = $aNotification['user_id'];
        $sender = Phpfox::getService('profiles.process')->getUser($sender_id);
        return array(
            'no_profile_image' => true,
            'link' => Phpfox::getLib('url')->makeUrl('profiles.manageinvite.'.$aNotification['notification_id']),  
            'message' => Phpfox::getPhrase('profiles.you_received_a_comment_by_a_persion_that_is_not_your_friend', array('sender'=>$sender['full_name'], 'receiver'=>'you'))
        );        
    }
    public function getNotificationInvitefirendsforfriend($aNotification){
        $receiver_id = $aNotification['user_id'];
        $receiver = Phpfox::getService('profiles.process')->getUser($receiver_id);
		
        return array(
            'no_profile_image' => true,
			'link' => Phpfox::getLib('url')->makeUrl(Phpfox::getUserBy('user_name').'/status-id_'.$aNotification['notification_id']),  
            'message' => Phpfox::getPhrase('profiles.a_site_member_has_posted_a_comment_about_you', array('sender'=>$sender['full_name'], 'receiver'=>'you'))
        );        
    }
    public function getNotificationRegistered($aNotification){
//        echo Phpfox::getPhrase('profiles.the_person_you_invited_registered', array('receiver'=>$receiver['full_name']));exit;
        $receiver_id = $aNotification['user_id'];
        $receiver = Phpfox::getService('profiles.process')->getUser($receiver_id);
        return array(
            'no_profile_image' => true,
            'message' => Phpfox::getPhrase('profiles.the_person_you_invited_registered', array('receiver'=>$receiver['full_name']))
        );        
    }
    public function getNotificationRefuseInvite($aNotification){
        $item_id = $aNotification['item_id'];
        if($item_id>0){
            $receiver = $this->database()->select("*, username as full_name")
                ->from(Phpfox::getT('profiles_user'))
                ->where('id='.$item_id)
                ->execute('getRow');
        }else{
            $receiver_id = $aNotification['user_id'];
            $receiver = Phpfox::getService('profiles.process')->getUser($receiver_id);
        }
        
        return array(
            'link' => '',
            'message' => Phpfox::getPhrase('profiles.refuse_message',array('receiver'=>$receiver['full_name'], 'sender'=>'your'))
        );        
    }

    public function getNotificationRefuseInvite1($aNotification){
        $receiver_id = $aNotification['user_id'];
        $receiver = Phpfox::getService('profiles.process')->getUser($receiver_id);
        
        return array(
            'link' => '',
            'message' => Phpfox::getPhrase('profiles.refuse_message',array('receiver'=>$receiver['full_name'], 'sender'=>'your'))
        );        
    }

    public function getNotificationAcceptInvite($aNotification){
        $item_id = $aNotification['item_id'];
        if($item_id>0){
            $receiver = $this->database()->select("*, username as full_name")
                ->from(Phpfox::getT('profiles_user'))
                ->where('id='.$item_id)
                ->execute('getRow');
        }else{
            $receiver_id = $aNotification['user_id'];
            $receiver = Phpfox::getService('profiles.process')->getUser($receiver_id);
        }
        
        return array(
//            'no_profile_image' => true,
            'link' => '',
            'message' => Phpfox::getPhrase('profiles.accept_message',array('receiver'=>$receiver['full_name'], 'sender'=>'your'))
//            'message' => Phpfox::getPhrase('profiles.accept_message',array('receiver'=>$receiver['full_name'], 'sender'=>'your'))
        );        
    }
    
    public function getNotificationAcceptInvite1($aNotification){
        
        $receiver_id = $aNotification['user_id'];
        $receiver = Phpfox::getService('profiles.process')->getUser($receiver_id);
        
        return array(
            'link' => Phpfox::getLib('url')->makeUrl(Phpfox::getUserBy('user_name').'/status-id_'.$aNotification['notification_id']),
            'message' => Phpfox::getPhrase('profiles.accept_message',array('receiver'=>$receiver['full_name'], 'sender'=>'your'))
        );        
    }

	/**
	 * If a call is made to an unknown method attempt to connect
	 * it to a specific plug-in with the same name thus allowing 
	 * plug-in developers the ability to extend classes.
	 *
	 * @param string $sMethod is the name of the method
	 * @param array $aArguments is the array of arguments of being passed
	 */
	public function __call($sMethod, $aArguments)
	{
		/**
		 * Check if such a plug-in exists and if it does call it.
		 */
		if ($sPlugin = Phpfox_Plugin::get('profiles.service_callback__call'))
		{
			eval($sPlugin);
			return;
		}

		/**
		 * No method or plug-in found we must throw a error.
		 */
		Phpfox_Error::trigger('Call to undefined method ' . __CLASS__ . '::' . $sMethod . '()', E_USER_ERROR);

	}

}

?>